package util;

import java.io.Serializable;

class Person implements Serializable, Cloneable{
    private String name;
    private int age;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        try {
            // 调用 Object 的 clone 方法
            return (Person) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError(); // 不可能发生的情况
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int[] getScores() {
        return scores;
    }

    public void setScores(int[] scores) {
        this.scores = scores;
    }

    private int[] scores;

    public Person(String name, int age, int[] scores) {
        this.name = name;
        this.age = age;
        this.scores = scores;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", scores=" + java.util.Arrays.toString(scores) +
                '}';
    }
}
